<?php namespace sacvoyage\http;

class Globals {
	
	public static function setSiteBaseUrl($url) {
		self::$_siteBaseUrl=rtrim($url, '/');
	}
	
	public static function getSiteBaseUrl() {
		return self::$_siteBaseUrl;
	}
	
	public static function setResourceName($name) {
		self::$_resourceName=trim($name, '/');
	}
	
	public static function getResourceBaseUrl() {
		return self::$_siteBaseUrl.'/'.self::$_resourceName;		
	}
	
	public static function redirect($path) {

		// remove initial '/' from $path
		if($path=='') {
			$path='/';
		} elseif(!starts_with($path, '/')) {
			$path='/'.$path;
		} 
		
		$location=self::getSiteBaseUrl().$path;
		header('Location: http://'.$location);
	}
	
	private static $_siteBaseUrl='';
	private static $_resourceName='';
}



?>